<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		[#include "/admin/include/head.htm"]
		<script type="text/javascript" src="${base}/resource/js/prettyprint.js"></script>
		<script type="text/javascript">
			$(function() {
			    $("#searchText").keyup(function(event) {
			        if(event.keyCode == 13) {
			            window.location.href = "?searchText=" + this.value + "&BackURL=<es:BackURL/>";
			        }
			    });
			
			    $(".btn-details").click(function() {
			        var td = $(this).closest("td");
			        var key = td.data("key");
			        var url = "${base}/admin/system/monitor/ehcache/${cacheName}/details.jhtml";
			        $.post(url, {key:key},function(data) {
			        	console.info(prettyPrint($.parseJSON(data.objectValue)));
			            var detail = $("<div'></div>");
			            var detailInfo = "";
			            detailInfo += "命中次数:" + data.hitCount;
			            detailInfo +=" | ";
			            detailInfo += "大小:" + data.size;
			            detailInfo +=" | ";
			            detailInfo += "最后创建/更新时间:" + data.latestOfCreationAndUpdateTime;
			            detailInfo +=" | ";
			            detailInfo += ",最后访问时间:" + data.lastAccessTime;
			            detailInfo +=" <br/> ";
			            detailInfo += "过期时间:" + data.expirationTime;
			            detailInfo +=" | ";
			            detailInfo += "timeToIdle(秒):" + data.timeToIdle;
			            detailInfo +=" | ";
			            detailInfo += "timeToLive(秒):" + data.timeToLive;
			            detailInfo +=" | ";
			            detailInfo += "version:" + data.version;
			
			            detailInfo +="<br/><br/>";
			             detailInfo +="键:"+key;
			            detailInfo +="<br/>值:<br/>";
			            detail.append(detailInfo);
						$('.detail').html(detail);
						$('.detail').append(prettyPrint($.parseJSON(data.objectValue)));
			        });
			    });
			
			    $(".btn-delete").click(function() {
			
			            var td = $(this).closest("td");
			            var key = td.data("key");
			            var url = "${base}/admin/system/monitor/ehcache/${cacheName}/delete.jhtml";
			            $.post(url,{key:key},function(data) {
			                td.closest("tr").remove();
			                $('.detail').empty();
			            });
			
			    });
			
			    $(".btn-clear").click(function() {
			        $.ligerDialog.confirm("确认清空整个缓存吗？",
			           	function (flag) {
			           		if(flag){
				           		var url = "${base}/admin/system/monitor/ehcache/${cacheName}/clear.jhtml";
				                $.get(url, function(data) {
				                    window.location.reload();
				                });
			           		}
			            }
			        );
			    });
			});
			
		</script>
	</head>
	<body style="overflow:hidden;padding:10px;">
		<div id="tabcontainer" style="overflow:hidden;margin:3px;">
			<div style="float:left;">
				<table class="inputTable">
					<tbody>
	
						<tr class="bold info">
							<td> <h1>${cacheName} 键列表</h1></td>
							<td>
								<a href="javascript:void(0);" onclick="history.go(-1);" class="button">返回</a>
								<a href="javascript:void(0);" class="btn-clear button">清空</a>
							</td>
						</tr>
						[#list keys as key]
							<tr>
								<th style="width: 75%">${key}</th>
								<td data-key="${key}"><a class="button btn-details">查看详细</a><a class="button btn-delete">删除</a></td>
							</tr>
						[/#list]
					</tbody>
				</table>
			</div>
			<div class="detail" style="float:left;padding:10px;overflow-y:auto;height:600px;" >
			</div>
		</div>
	</body>
</html>